package com.hphs.controller;

import com.hphs.dto.ResponseDTO;
import com.hphs.model.Category;
import com.hphs.model.CategoryQuery;
import com.hphs.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/category")
public class CategoryController {
    @Autowired
    private CategoryService service;

//    @GetMapping
//    public ResponseDTO select(CategoryQuery query){
//        List<Category> select = service.select(query);
//        return ResponseDTO.success(select);
//    }

    @GetMapping
    public List<Category> select(CategoryQuery query){

        return service.select(query);
    }

    @PostMapping
    public int insert(@RequestBody Category category){
        return service.insert(category);
    }
    @PutMapping
    public int update(@RequestBody Category category){
        return service.update(category);
    }

    //删除 软删除
    @DeleteMapping
    public  int delete(Integer id){
        return service.delete(id);
    }
}
